'''
Author: gaoh
Date: 2023-08-13 16:12:16
LastEditTime: 2023-08-13 16:43:09
'''

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait


def openBroser():
    broser=webdriver.Chrome()
    try:
        broser.get('https://www.baidu.com')
        input=broser.find_element_by_id('kw')
        input.send_keys('Python')
        input.send_keys(Keys.ENTER)
        wait=WebDriverWait(broser,10)
        wait.until(EC.presence_of_element_located((By.ID, 'content_left')))
        print(broser.current_url)
        print(broser.get_cookies())
        print(broser.page_source)

    finally: 
        broser.close()
    

def openTaobao():
    broser=webdriver.Chrome()
    try:
        broser.get('https://www.taobao.com')
        print(broser.current_url)
        input_frist= broser.find_element_by_id('q')
        input_second= broser.find_element_by_css_selector('#q')
        input_third= broser.find_element_by_xpath('//*[@id="q"]')
        print(input_frist,input_second,input_third)

    finally:
        broser.close()

    

if __name__ == '__main__':
    # openBroser()
    openTaobao()


